/**
 * Created by Administrator on 2015/11/22.
 */

//
//['abc','bcd'].forEach(function(e){
//    console.log(e);
//});

var myobj = {};
var objVal ;
myobj.dd = 'dongge';
['open','close','write','test'].forEach(function(name){
   Object.defineProperty(myobj,name,{
       get: function(){
            console.log(name + ' is getter!');
            return objVal;
       },
       set:function(newValue){
            console.log('set new value');
           objVal = newValue;
       },
       configurable:true,
       enumerable:true
   })
});
console.log(Object.keys(myobj));
myobj.open = function(){
    console.log('open function is calling');
};
myobj.open();
for(var prop in myobj){
    console.log(prop);
}